package com.hfb.mashibing.alip8.jvm.jmm;

public class T01_CacheLinePadding {
    private static class T {
        public volatile long x = 0L;
    }
    public static T[] arr = new T[2];
    static {
        arr[0] = new T();
        arr[1] = new T();
    }

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            for (long i = 0; i < 1000_0000L; i++) {
                arr[0].x = i;
            }
        });
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 1000_0000; i++) {
                arr[1].x = i;
            }
        });
        final long s = System.nanoTime();
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        final long e = System.nanoTime();
        System.out.println((e-s)/100_0000);
    }
}
